package com.zhiyou.app.shop.website.service.impl;

import java.util.List;

import org.hibernate.criterion.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou.app.shop.common.util.Page;
import com.zhiyou.app.shop.common.util.ShopConstants;
import com.zhiyou.app.shop.website.dao.INewsDao;
import com.zhiyou.app.shop.website.dao.pojo.News;
import com.zhiyou.app.shop.website.service.INewsService;

@Service(value="newsService")
public class NewsServiceImpl implements INewsService {

	@Autowired
	private INewsDao newsDao;
	
	public void getNews(Page page) {
		newsDao.findByExample(page, new News(), Order.desc("createDate"));
		//return null;
	}

	public void getNewsByType(Page page, String type) {
		News news = new News();
		news.setType(type);
		news.setFlag(ShopConstants.TRUE);
		newsDao.findByExample(page, news, Order.desc("createDate"));
		
	}

	public void saveNews(News news) {
		newsDao.save(news);
		
	}

	public News findById(String id) {
		return newsDao.findById(id);
	}

	public void delete(News news){
		newsDao.delete(news);
	}

}
